package com.zwf.mapper;

import com.zwf.entity.SetmealDish;
import com.zwf.vo.DishItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author zwf
 * @date 2024/2/3 15:59
 */

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询是否有与其关联的套餐
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal_dish where dish_id=#{id}")
    int queryByDishId(Long id);

    /**
     * 根据套餐id查询包含的菜品
     * @param id
     * @return
     */
    @Select("select s.copies,d.description,d.name,d.image from setmeal_dish s left join dish d on s.dish_id=d.id " +
            "where s.setmeal_id=#{id}")
    List<DishItemVO> queryBySetmealId(Long id);

    /**
     * 根据套餐id查询包含的菜品的所有信息
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish s left join dish d on s.dish_id=d.id " +
            "where s.setmeal_id=#{id}")
    List<SetmealDish> queryDishAllBySetmealId(Long id);

    /**
     * 新增套餐菜品
     * @param setmealDishes
     */
    void add(List<SetmealDish> setmealDishes);

    /**
     * 根据套餐id批量删除
     * @param ids
     */
    void delete(List<Long> ids);
}
